package com.znn.dagger2demo;

import android.content.Context;
import android.location.LocationManager;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.widget.TextView;

import com.google.gson.Gson;
import com.znn.dagger2demo.bean.TestBean;
import com.znn.dagger2demo.component.DaggerMainActivityComponent;
import com.znn.dagger2demo.module.MainActivityModule;

import javax.inject.Inject;

public class MainActivity extends AppCompatActivity {


    @Inject
    LocationManager locationManager;

    @Inject
    TestBean testBean;

    @Inject
    Gson gson;

    @Inject
    Context context;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        DaggerMainActivityComponent.builder()
                .mainActivityModule(new MainActivityModule(this))
                .applicationComponent(MyApplication.getInstance().getComponent())
                .build()
                .inject(this);
        TextView textView = (TextView) findViewById(R.id.text);

        Log.i("", "locationManager:"+Integer.toHexString(locationManager.hashCode()));
        Log.i("", "gson:"+Integer.toHexString(gson.hashCode()));

        Log.i("", "locationManager:"+locationManager.toString());
        textView.setText(locationManager.toString());
        textView.append("\n");
        textView.append(testBean.getMsg());
        textView.append("\n");
        textView.append(gson.toString());
    }
}
